package com.xindong.paking.dtos;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Calendar;

/**
 * @Author jielun
 * @Date 2023/3/18 11:45
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MonthOrderDto {

    private String yearAndmonth;

    private Float orderNumber;

    public void initData(int monthBefore, Float orderNumber) {
        Calendar calendar = Calendar.getInstance();
        int month = calendar.get(Calendar.MONTH) - monthBefore + 1;
        int year = calendar.get(Calendar.YEAR);
        if (month <= 0) {
            month += 12;
            year -= 1;
        }
        yearAndmonth = String.valueOf(year) + '.' + String.valueOf(month);
        this.orderNumber = orderNumber;
    }
}
